#ifndef AUTOAIM_DETECTOR__DESCRIPTOR_HPP_
#define AUTOAIM_DETECTOR__DESCRIPTOR_HPP_

#include <opencv2/opencv.hpp>

namespace detector {

constexpr int RED = 0;
constexpr int BLUE = 1;

struct Light : public cv::RotatedRect {
  Light() = default;
  explicit Light(cv::RotatedRect box) : cv::RotatedRect(box) {
    cv::Point2f p[4];
    box.points(p);
    std::sort(p, p + 4, [](const cv::Point2f &a, const cv::Point2f &b) {
      return a.y < b.y;
    });
    top = (p[0] + p[1]) / 2;
    bottom = (p[2] + p[3]) / 2;

    length = cv::norm(top - bottom);
    width = cv::norm(p[0] - p[1]);

    tilt_angle =
        std::atan2(std::abs(top.x - bottom.x), std::abs(top.y - bottom.y));
    tilt_angle = tilt_angle / CV_PI * 180;
  }

  int color;
  cv::Point2f top, bottom;
  double length;
  double width;
  float tilt_angle;
};

struct Armor {
  Armor() = default;
  Armor(const Light &l1, const Light &l2) {
    if (l1.center.x < l2.center.x) {
      left_light = l1, right_light = l2;
    } else {
      left_light = l2, right_light = l1;
    }
    //    center = (left_light.center + right_light.center) / 2;
  }

  Light left_light, right_light;
  //  cv::Point2f center;

  cv::Mat number_img;
  //  cv::Rect bounding_rect;
  int number;
  float confidence;
  bool is_big;
};

}  // namespace detector
#endif  // AUTOAIM_DETECTOR__DESCRIPTOR_HPP_